// pages/detail-video/detai-video.js
import { getMvUrl, getMvInfo, getMVRelated } from '../../../services/video'
Page({
  data: {
    id: 0,
    mvUrl: '',
    mvInfo: {},
    releatedVideo: [],
    danmuList: [
      { text: '哈哈哈, 真好听', color: '#ff0000', time: 3 },
      { text: '呵呵呵, 不错哦', color: '#ffff00', time: 10 },
      { text: '嘿嘿嘿, 好喜欢', color: '#0000ff', time: 15 },
    ]
  },

  onLoad(options) {
    // 1. 获取id
    const id = options.id;
    this.setData({ id })

    //2. 请求数据
    this.fetchMvUrl()
    this.fetchMVInfo()
    this.fetchMVRelated()
  },

  async fetchMvUrl() {
    const res = await getMvUrl(this.data.id)
    this.setData({ mvUrl: res.data.url })
  },

  async fetchMVInfo() {
    const res = await getMvInfo(this.data.id)
    this.setData({ mvInfo: res.data })
  },

  async fetchMVRelated() {
    const res = await getMVRelated(this.data.id)
    console.log(res);
    this.setData({ releatedVideo: res.data })
  }

})